Skip to content

fix(sidekick/swift): omit default enum values - #7968

Merged
coryan merged 1 commit into
googleapis:mainfrom
coryan:fix-issue-828
Nov 24, 2026
Merged

coryan merged 1 commit into
googleapis:mainfrom
coryan:fix-issue-828

Conversation

@coryan

@coryan coryan commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Update the Swift code generator to support Proto3 default value omission in _ProtoJSONEncoder while preserving explicit presence for optional and oneof fields.

Non-optional singular enum fields are now guarded so default enum values are omitted during encoding. Oneof variants and optional singular Discovery URL-safe byte fields now use encodeIfPresent so explicit zero and empty values remain present in the serialized JSON.

Towards googleapis/google-cloud-swift#828

Generated draft at googleapis/google-cloud-swift#1677

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines Swift code generation by introducing distinct encoding styles, specifically EncodingOptional and EncodingSingularEnum. It updates the field annotation logic to classify fields accordingly and modifies the Swift templates to use encodeIfPresent for optional and oneof fields, and conditional encoding for singular enums to avoid encoding default values. Corresponding unit and integration tests have been added and updated to validate the generated Swift code. There are no review comments, and I have no feedback to provide.

@coryan
coryan marked this pull request as ready for review November 20, 2026 22:13
@coryan
coryan requested a review from a team as a code owner November 20, 2026 22:13
Update the Swift code generator to support Proto3 default value omission
in _ProtoJSONEncoder while preserving explicit presence for optional and
oneof fields.

Non-optional singular enum fields are now guarded so default enum
values are omitted during encoding. Oneof variants and optional singular
Discovery URL-safe byte fields now use encodeIfPresent so explicit zero
and empty values remain present in the serialized JSON.
@coryan
coryan enabled auto-merge (squash) November 24, 2026 19:52
@coryan
coryan merged commit 90c3a4e into googleapis:main Nov 24, 2026
47 checks passed
@coryan
coryan deleted the fix-issue-828 branch November 24, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants